import os
import hashlib

taggerDir = os.path.expanduser('~/.tagger')
workDir='.WORKDIR'
workDirPath = os.path.join(taggerDir,workDir)

def getTags(md5str):
   # I sshould use a faster way to get this maybe this is a good place
   # for extended attributes
   """Use it to obtain a list with all the tags of a file"""
   tags=[]
   for root, dirs, files in os.walk(taggerDir):
      tag = os.path.basename(root)
      if md5str in files:
	 tags.append(tag)
      if workDir in dirs:
	 dirs.remove(workDir) #dont walk in here

   return set(tags)

def qMd5(fullpath):
   """Quickly return the md5 sum of fullpath"""
   m=hashlib.md5()
   m.update(fullpath)
   return m.hexdigest()


